package com.qf.mapper;

import com.qf.entity.User;
import com.qf.entity.UserExample;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {
    long countByExample(UserExample example);

    int deleteByExample(UserExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(User record);

    int insertSelective(User record);

    List<User> selectByExample(UserExample example);

    User selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);

    int updateByExample(@Param("record") User record, @Param("example") UserExample example);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    /**
     * 减钱操作
     *
     * @param decrementUserId
     * @param money
     */
    @Update("update user set money = money - #{money} where id = #{id}")
    int decrementMoneyById(@Param("id") Integer decrementUserId, @Param("money") Integer money);

    /**
     * 加钱操作
     * @param incrementUserId
     * @param money
     */
    @Update("update user set money = money + #{money} where id = #{id}")
    int incrementMoneyById(@Param("id") Integer incrementUserId,@Param("money") Integer money);
}